import request from '@/utils/request'

/**
 * 获取分页数据
 * @param {*} data 搜索条件
 */
export function addressPage(data, startPage, pageSize) {
  return request({
    url: `/address/page/${startPage}/${pageSize}`,
    method: 'POST',
    data
  })
}

/**
 * 根据id删除数据
 * @param {*} id 搜索条件
 */
export function addressDeleteByUserId(id) {
  return request({
    url: `/address/del/${id}`,
    method: 'delete',
  })
}

/**
 * 批量删除多条数据
 * @param {*} ids id数组
 */
export function addressDeleteBatch(ids) {
  return request({
    url: `/address/deleteBatch`,
    method: 'delete',
    data: ids
  })
}

/**
 * 添加一条数据
 * @param {*} data 添加的数据
 * @returns
 */
export function addressAdd(data) {
  return request({
    url: `/address/add`,
    method: 'post',
    data
  })
}

/**
 * 根据Id查询数据
 * @param {*} id 查询的Id
 * @returns
 */
export function addressGetById(id) {
  return request({
    url: `/address/getById/${id}`,
    method: 'get',
  })
}

/**
 * 获取用户默认地址
 * @returns
 */
export function addressGetDefaultAddress() {
  return request({
    url: `/address/getDefault`,
    method: 'get',
  })
}


/**
 * 修改一条数据
 * @param {*} data 修改的数据
 * @returns
 */
export function addressEdit(data) {
  return request({
    url: `/address/edit`,
    method: 'post',
    data
  })
}
